package com.orange.core.service.activityRegistration.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.orange.core.mapper.activityRegistration.ActivityRegistrationMapper;
import com.orange.core.pojo.entity.activityRegistration.ActivityRegistration;
import com.orange.core.service.activityRegistration.ActivityRegistrationService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
* @author lwm
* @description 针对表【activity_registration(活动报名表)】的数据库操作Service实现
* @createDate 2025-06-04 15:16:58
*/
@Service
@RequiredArgsConstructor
public class ActivityRegistrationServiceImpl extends ServiceImpl<ActivityRegistrationMapper, ActivityRegistration>
    implements ActivityRegistrationService {

//   private final ActivityMapper activityMapper;


   /* @Override
    public Boolean save(ActivityRegistrationDTO activityRegistrationDTO) {
        Integer activityId = activityRegistrationDTO.getActivityId();
        Integer userId = activityRegistrationDTO.getUserId();
        if (activityId != null && userId != null) {
            LambdaQueryWrapper<ActivityRegistration> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(ActivityRegistration::getActivityId, activityId)
                    .eq(ActivityRegistration::getUserId, userId);
            ActivityRegistration activityRegistration = this.getOne(queryWrapper);
            Assert.notNull(activityRegistration, "该用户已经报名过该活动");
            if (activityRegistration == null) {
                // 没有报名过，则进行报名
                ActivityRegistration registration = new ActivityRegistration();
                BeanUtil.copyProperties(activityRegistrationDTO, registration);
                boolean result = this.save(registration);
                if (result) {
                    // 报名成功，更新活动报名人数
                    activityMapper.updateRegistrationCount(activityId, 1);
                }
                return result;
            }
        }
        return false;
    }*/
}




